<script src="adminfunctions.js" type="text/javascript"></script>


function User(id, username, lastname, address, phoneNumber, email) {
    var user = new Object();
    user.id = id;
    user.username = username;
    user.lastname = lastname;
    user.address = address;
    user.phoneNumber = phoneNumber;
    user.email = email;

    return user;
}
function updateUser() {
    var form = document.forms["updateUserForm"];
    var id = form.id.value;
    var username = form.username.value;
    var firstname = form.firstname.value;
    var lastname = form.lastname.value;
    var address = form.address.value;
    var phoneNumber = form.phoneNumber.value;
    var email = form.email.value;

//    alert(id + username + firstname +
//    lastname + address + phoneNumber + email);
    //Validate here

    var user = User(id, username, lastname, address, phoneNumber, email);
    var xmlUserDoc = loadUserXMlFile();
    updateUserNode(xmlUserDoc, user);
}

function updateUserNode(node, user) {

    var path = "/users/user[@id = '"+ user.id +"']";
    var iterator = xml.evaluate(path, node, null, XPathResult.FIRST_ORDERED_NODE_TYPE ,null);

    try {
        var thisNode = iterator.iterateNext();
        alert(thisNode);
       
    }catch (e) {
        dump('Error : Document tree when updating.' + e);
    }

}

